package com.cn.wanxi.model;

public class ResultModel {
    private Integer code;
    private String msg;
    private Integer count;
    private Object data;


    /**
     * 根据影响的条数得到结果
     *
     * @param count
     * @return
     */
    public static ResultModel getResult(int count) {
        ResultModel resultModel = new ResultModel();
        resultModel.setCount(count);
        return resultModel;
    }

    /**
     * 根据id查询得到的结果
     *
     * @param data
     * @return
     */
    public static ResultModel getResult(Object data) {
        ResultModel resultModel = new ResultModel();
        resultModel.setCode(0);
        resultModel.setMsg("");
        resultModel.setData(data);
        return resultModel;
    }

    public static ResultModel getResult(String msg) {
        ResultModel resultModel = new ResultModel();
        resultModel.setCode(0);
        resultModel.setMsg(msg);
        resultModel.setData(null);
        return resultModel;
    }

    /**
     * 查询总条数和查询所有结果得到结果集
     *
     * @param count
     * @param data
     * @return
     */
    public static ResultModel getResult(int count, Object data) {
        ResultModel resultModel = new ResultModel();
        resultModel.setCode(0);
        resultModel.setCount(count);
        resultModel.setData(data);
        return resultModel;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
